﻿@model DAL.Banner
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BJ</title>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="~/lib/layui/layui.js"></script>
    <script src="~/js/jquery.min.js"></script>
</head>
<body>
    <form id="fSelf" class="layui-form">
        <input type="hidden" name="Id" value="@Model.Id" class="layui-input" />
        <div class="layui-form-item">
            <label class="layui-form-label">电影名</label>
            <div class="layui-input-inline">
                <input type="text" name="ImageNames" class="layui-input" value="@Model.ImageNames" />
            </div>
        </div>
        <div class="layui-upload">
            <label class="layui-form-label">电影图片</label>
            <input type="text" id="imgurl" name="Image" style="display:none;" lay-verify="required" placeholder="请上传图片" autocomplete="off" class="layui-input" value="@Model.Image" />
            <div class="layui-input-inline">
                <img id="demo1" src="@Model.Image" class="layui-upload-img" style="width:320px; height:213px" />
                <button type="button" class="layui-btn" id="uploadImg">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                    <button>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" style="background-color:#009688" lay-submit lay-filter="save">保存<button>
            </div>
        </div>
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
    </form>
    <script>
        layui.use(['form', 'layer', 'layedit', 'upload'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer,
                layedit = layui.layedit,
                upload = layui.upload;

            layedit.set({
                uploadImage: {
           //服务器端需要定义LayEditUploadPhoto方法来进行相应的处理
                    url: '/Product/Upalod',
                    type: 'post' //默认post
                }
            });
            var index = layedit.build('aboutMe');
            upload.render({
                elem: '#uploadImg',
          
                url: '/Product/Upalod',
                done: function (res, index, upload) {
                    var item = this.item;
                    if (res.status) {
                        $("#imgurl").val(res.remark);
                        $("#demo1").attr("src", "/" + res.remark);
                        layer.msg("上传成功");
                    }
                    else
                        layer.msg("上传失败:" + res.message);
                }
            })
            form.on('submit(save)', function (data) {
                layedit.sync(index); //可以将index对应的layedit内容同步到textarea控件中，这样提交的数据带有html标签了。

                $.post("/Product/BJ", $("#fSelf").serialize(), function (res) {
                    if (res.success) {
                        layer.msg("添加成功", function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //修改成功后刷新父界面
                            window.parent.location.reload();
                        });
                    }
                    else {
                        layer.alert("添加失败:" + res.message, { icon: 5 });
                    }
                }, "json");
                return false; //不再进行传统提交
            });
        });
    </script>
</body>
</html>
